package cn.sc.summer.core.config.js;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

/**
 * @author a-xin
 * @description java代码执行js代码引擎
 * @belongsProject SummerCloud
 * @belongsPackage cn.sc.summer.core.config.js
 * @date 2025-02-12  14:00
 */
@Slf4j
@Configuration
public class JsEngineConfig {

    /**
     * js引擎名称
     */
    private static final String ENGINE_NAME = "javascript";

    @Bean
    public ScriptEngine createScriptEngine() {
        log.info("==> Start initialize the JS engine...");
        return new ScriptEngineManager().getEngineByName(ENGINE_NAME);
    }

}
